<?php
/**
 * 后台用户模型类
 */

namespace Apps\Acp\Models;

use Apps\Common\Model\BaseModel;

/**
 * Class Goods
 * @package Apps\Acp\Models
 */
class Campaign extends BaseModel
{
    // 定义此model访问的数据库名
    protected static $_DBNAME = 'yyx_fanli';

    // 定义此model访问的表名
    protected static $_TABLENAME = 'campaign';

    public function getListByConds($conditions, $offset, $limit)
    {
        list($values, $conds, $likeConds) = $this->assembleConditionsData($conditions);
        $where = $this->assembleComplexWhereSql($conds, $likeConds);

        $sql = 'SELECT * FROM ' . self::$_TABLENAME . $where . ' ORDER BY  id DESC ' . $this->assembleLimit($offset, $limit);

        return $this->select($sql, $values);
    }

    public function countListByConds($conditions)
    {
        list($values, $conds, $likeConds) = $this->assembleConditionsData($conditions);
        $where = $this->assembleComplexWhereSql($conds, $likeConds);

        $sql = 'SELECT COUNT(*) AS num FROM ' . self::$_TABLENAME . $where;

        return $this->selectCount($sql, $values);
    }

}
